<!--  -->
<template>
  <div class="head">
    <div class="top">
      <a href="javascript:;" @click="logOutFn">退出</a>
    </div>
  </div>
</template>

<script>
import { logOut } from "@/api/api.js";
export default {
  components: {},
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {
    logOutFn() {
      this.$confirm("是否确定退出?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          console.log(1)
          this.logOut();
        })
        .catch(() => {
          console.log(2)
          // this.$message({
          //   type: "info",
          //   message: " 退出失败"
          // });
        });
      
    },
    async logOut(){
      var data = await logOut();
      if (data.data.code == 200) {
        if (sessionStorage.getItem("userInfo")) {
          sessionStorage.removeItem("userInfo", JSON.stringify(data.data.data));
        }
        this.$router.push("/login");
      }
    }

  },
  created() {},
  mounted() {}
};
</script>
<style  scoped lang="scss">
.head {
  color: red;
  .top {
    font-size: 18px;
    line-height: 60px;
    text-align: right;
  }
}
</style>